package com.ag.oa.core.controller;

import com.ag.oa.core.entity.vo.QAUserVO;
import com.ag.oa.core.service.IQAUserService;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@CrossOrigin(origins = {"http://localhost:8080"},allowCredentials = "true")
@CrossOrigin
@RestController
@RequestMapping({"/getQAUser"})
public class QAUserController {

    @Autowired
    private IQAUserService qauserService;

    private static final Logger logger = LoggerFactory.getLogger(QAUserController.class);

    @RequestMapping(value = "/getName",produces = "text/json;charset=UTF-8")
    public @ResponseBody String getUserData(String id){

        JSONObject res = new JSONObject();
        int code = 200;
        try {
            List<QAUserVO> voList = qauserService.getUserBigNameById(id);
            res.put("userList",voList);
        }catch (Exception e){
            e.printStackTrace();
            code = 500;
            logger.error(e.getMessage());
        }
        res.put("resCode",code);
        return  res.toJSONString();
    }
}
